package com.hou.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hou.mapper.BasicOrderMapper;
import com.hou.parma.PageParam;
import com.hou.pojo.BasicOrder;
import com.hou.pojo.Order;

import com.hou.service.IBasicOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jack
 * @since 2022-04-11
 */
@Service

public class BasicOrderServiceImpl extends ServiceImpl<BasicOrderMapper, BasicOrder> implements IBasicOrderService {
    @Autowired
    BasicOrderMapper orderMapper;

    @Override
    public List selectList(PageParam pageParam) {
        List<BasicOrder> records = orderMapper.selectPage(new Page<>(pageParam.getCurrentPage(), pageParam.getPageSize()), null).getRecords();
        return records;
    }

    @Override
    public Long selectCount() {
        Long aLong = orderMapper.selectCount(new QueryWrapper<BasicOrder>());
        return aLong;
    }

    @Override
    public Long selectCoun(Long id) {
        Long id1 = orderMapper.selectCount(new QueryWrapper<BasicOrder>().like("id", id));
        return id1;
    }

    @Override
    public BasicOrder selectList_Byid(Long id) {
        BasicOrder order = orderMapper.selectById(id);
        return order;
    }

    @Override
    public List<BasicOrder> selectList_Asc(PageParam pageParam) {
        List<BasicOrder> records = orderMapper.selectPage(new Page<>(pageParam.getCurrentPage(), pageParam.getPageSize()), new QueryWrapper<BasicOrder>().select().orderByAsc("createDate")).getRecords();
        return records;
    }

    @Override
    public List<BasicOrder> selectList_ByName(PageParam pageParam) {
        List<BasicOrder> records = orderMapper.selectPage(new Page<>(pageParam.getCurrentPage(), pageParam.getPageSize()), new QueryWrapper<BasicOrder>().like("id",pageParam.getSearch())).getRecords();
        return records;
    }

    @Override
    public List<BasicOrder> selectList_Desc(PageParam pageParam) {
        List<BasicOrder> records = orderMapper.selectPage(new Page<>(pageParam.getCurrentPage(), pageParam.getPageSize()), new QueryWrapper<BasicOrder>().select().orderByDesc("createDate")).getRecords();
        return records;
    }
}
